﻿@{
    Layout = null;
}

@using MVC.Models.Database

@{
    var users = ViewData["User"] as List<User>;
}
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户管理</title>
    <link rel="stylesheet" href="/css/admin1.css">
    <link rel="stylesheet" href="/css/admin2.css">
</head>
<body style="background-color:#008c8c">

    <!-- 头部 -->
    <div class="nav">
        <ul>
            <li class="current"><a href="/Umanagement">用户管理</a></li>
        </ul>




                <!--信息展示-->

                <table width="100%">
                    <tr>
                        <th>编号</th>
                        <th>用户名 </th>
                        <th>密码</th>
                        <th>邮箱</th>
                        <th><a href="~/AddU">添加</a></th>
                        <th><a href="~/UpdateA">编辑</a></th>
                    </tr>
                    @{foreach (var item in users)
                        {
                                        <tr>
                                            <td> @item.UserId </td>
                                            <td> @item.UserName </td>
                                            <td> @item.UserPassword </td>
                                            <td> @item.UserEmail  </td>
                                            @* <td colspan="2"><a href="/Dele/@item.UserId">删除 </a></td> *@
                                            <td colspan="2"><a href="javascript:delAccount(@item.UserId)">删除 </a></td>
                                        </tr>

                        }
                    }
                </table>
                <!--信息展示-->
    </div>

</body>
</html>
<script src="/js/jquery-3.6.0.min.js"></script>
<script>
function delAccount(id) {
    $.ajax({
        url: "/Dele/" + id,
        type: "post",
        success: function (data) {
            if (data.code == 200) {
                alert("删除成功");
                window.location.reload();
            }
            else {
                alert("删除失败");
            }
        }
    });
}
</script>